﻿using SmartHRMS.Model.Company;
using System;

namespace SmartHRMS.NhibernateRepository
{
    public class CompanyRepository : BaseRepository<Company>, ICompanyRepository
    {
        #region ICompanyProfileRepository Members

        public Company LoadCompanyProfile()
        {
            Company company = SessionFactory.GetCurrentSession().CreateQuery("select o from Company o").UniqueResult<Company>();

            //if (company.CompanyId != Guid.Empty)
            //{
            //    LoadCompanyAddress(company.CompanyId);
            //}
            return company;
        }

        public CompanyAddress LoadCompanyAddress(Guid Companyid)
        {
            CompanyAddress companyAddress = SessionFactory.GetCurrentSession().CreateQuery("select o from CompanyAddress o where o.CompanyId = :CompanyId").SetGuid("CompanyId", Companyid).UniqueResult<CompanyAddress>();

            return companyAddress;
        }
        #endregion
    }
}
